package com.java.strategy;

public enum PayEnum {

    ALIPAY("ALIPAY",new Alipay()),

    WECHATPAY("WECHATPAY",new WeChatPay())
    ;
    private String payPlatform;

    private AbstractPay payBean;

    PayEnum(String payPlatform, AbstractPay payBean) {
        this.payPlatform = payPlatform;
        this.payBean = payBean;
    }

    public String getPayPlatform() {
        return payPlatform;
    }

    public static AbstractPay getPayBeanByCode(String payPlatform) {
        for (PayEnum value : PayEnum.values()) {
            if (value.getPayPlatform().equals(payPlatform)){
                return value.getPayBean();
            }
        }
        return null;
    }

    public AbstractPay getPayBean() {
        return payBean;
    }
}
